package com.glorysoft.hlgdpda.model

import com.glorysoft.hlgdpda.base.BaseRepository
import com.glorysoft.hlgdpda.base.Constant
import com.glorysoft.hlgdpda.entity.AuthorityListEntity
import com.glorysoft.hlgdpda.entity.LoginEntity
import com.google.gson.JsonObject
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse


/**
 * FileName: LoginRepository
 * Author: XJH
 * Date: 2021/5/24 17:11
 * Description:
 * History:
 */
class LoginRepository : BaseRepository() {
    private val MES_URL = "/esbrest/RestService/postrequest"

    suspend fun getLogin(map: JsonObject): LoginEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + MES_URL)
            .addAll(getInJsonData(map,"SYS.USER_LOGIN"))
            .toResponse<LoginEntity>()
            .await()


    }

    suspend fun getAuthority(map: JsonObject): AuthorityListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + MES_URL)
            .addAll(getInJsonData(map,"SYS.USER_GETAUTHORITY"))
            .toResponse<AuthorityListEntity>()
            .await()
    }
}